import requests
import json

def tran(word):

    url='http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule'

    headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36'
}

    data = {
    'i':word,
    'from':'AUTO',
    'to':'AUTO',
    'smartresult':'dict',
    'client':'fanyideskweb',
    'salt':'15645850291596',
    'sign':'1604666f7d7cce509481fc15d2d363a4',
    'ts':'1564585029159',
    'bv':'f0325f69e46de1422e85dedc4bd3c11f',
    'doctype':'json',
    'version':'2.1',
    'keyfrom':'fanyi.web',
    'action':'FY_BY_REALTlME',
}

    res = requests.post(url,headers=headers,data=data)
    js = res.json()
    print(js)

if __name__ == "__main__":
    word = input('输入要翻译的单词:')
    tran(word)